<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
<script type="text/javascript" src="http://libs.useso.com/js/respond.js/1.4.2/respond.min.js"></script>
<script type="text/javascript" src="http://cdn.bootcss.com/css3pie/2.0beta1/PIE_IE678.js"></script>
<![endif]-->
<!-- <link type="text/css" rel="stylesheet" href="/admin/static/h-ui/css/H-ui.css"/>
<link type="text/css" rel="stylesheet" href="css/H-ui.admin.css"/>
<link type="text/css" rel="stylesheet" href="font/font-awesome.min.css"/> -->
<!--[if IE 7]>
<link href="http://www.bootcss.com/p/font-awesome/assets/css/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />


<title>分类编辑</title>
</head>
<body>


<article class="page-container">
 <form action="" method="post" class="form form-horizontal" id="form-member-add">
    @foreach ($datas as $val)
   <div class="row cl">
    <input type="hidden" name="id" value="{{$val->id}}">
      <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>名称：</label>
      <div class="formControls col-xs-8 col-sm-9">
         
        <input type="text" class="input-text" value="{{$val->name}}" placeholder="" id="name" name="name">
        
      </div>
    </div>

      
     <div class="row cl">
      <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
      <div class="formControls col-xs-8 col-sm-9">
        <input type="text" class="input-text" value="{{$val->sort}}" placeholder="" id="sort" name="sort">
      </div>
    </div>
    
     <div class="row cl">
      <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>父分类：</label>
    
        <div id="demo3" class="citys" >
          <div class="formControls col-xs-8 col-sm-9" > 
          
          <select  class="select-box" style="width:150px;" name="pid" id="pid" size="1" >
               <option value="0">无</option>
            @foreach ($result as $res)
            <option value="{{$res->id}}" @if($res->id == $val->pid) selected='selected'  @endif>{{str_repeat('----',$res->level*2)}}{{$res->name}} 
            </option>
            @endforeach
          </select>
                
          </div>
        </div>     
    </div>
  @endforeach
  
   <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
    </div>
    {{csrf_field()}}
  </form>
</article>
<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/admin/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script type="text/javascript">
$(function(){

  
  $('.skin-minimal input').iCheck({
    checkboxClass: 'icheckbox-blue',
    radioClass: 'iradio-blue',
    increaseArea: '20%'
  });
  
  $("#form-member-add").validate({
    rules:{
      name:{
        required:true,
        minlength:2,
        maxlength:20
      },
      sort:{
        required:true,
      },
   
      pid:{
        required:true,
    
      },

      
    },
    onkeyup:false,
    focusCleanup:true,
    success:"valid",
    submitHandler:function(form){
        $(form).ajaxSubmit({
        type: 'post',
        url: "" ,
        success: function(data){
          if (data == '1'){
          layer.msg('更新成功!',{icon:1,time:1000},function(){
            var index = parent.layer.getFrameIndex(window.name);
            // parent.$('.btn-refresh').click();
            parent.window.location = parent.window.location;
            parent.layer.close(index);

          });

        }else{
          layer.msg('更新失败!',{icon:2,time:2000});
          }
          
        },
          error: function(XmlHttpRequest, textStatus, errorThrown){
          layer.msg('error!',{icon:2,time:1000});
        }
      });
    }
  });
});



</script>
</body>
</html>